import { Inject } from '@midwayjs/core';
import { CoolController, BaseController } from '@cool-midway/core';
import { StudentPrescriptionEntity } from '../../entity/prescription';
import { StudentPrescriptionService } from '../../service/prescription';
import { StudentStudentEntity } from '../../entity/student';

/**
 * APP处方控制器
 */
@CoolController({
  api: ['add', 'delete', 'update', 'info', 'list', 'page'],
  entity: StudentPrescriptionEntity,
  service: StudentPrescriptionService,
  pageQueryOp: {
    keyWordLikeFields: ['a.remark'],
    fieldEq: ['a.studentId'],
    select: ['a.*', 'b.name as studentName'],
    join: [
      {
        entity: StudentStudentEntity,
        alias: 'b',
        condition: 'a.studentId = b.id',
        type: 'leftJoin',
      },
    ],
  },
})
export class AppStudentPrescriptionController extends BaseController {
  @Inject()
  studentPrescriptionService: StudentPrescriptionService;
}
